#ifndef PREFILTER_HPP
#define PREFILTER_HPP

class image;

/**
 * Class to tidy up and simplify raw captcha images.
 */
class prefilter
{
  public:

	static void equalize(image& img, const unsigned int nb_levels);
	static void toGrayscale(image& img);
	static void toBlackAndWhite(image& img); /**< Make image monochrome.*/

	/**
	 * Fills the background with desired color leaving text untouched.
	 *
	 * Method calculates the average darkness of a line of pixels. If it's
	 * much different than that of the center line that most probably is
	 * text's typical darkness value, then that line of pixels probably
	 * belong to the background. This is done iteratively to horizontal
	 * pixel lines of images width, width/2, width/4 and so on. Finally
	 * all estimates are combined and background is painted over.
	 *
	 * @param	img The target image.
	 * @param	color Color that the background is paited over with.
	 *       	      Defaults to RGB(255, 255, 255), i.e. white.
	 */
	static void removeBackground(image& img, const unsigned char* color);

	static void sharpen(image& img, const float amplitude);

  private:
	prefilter(); // Deny instantation - force into singleton.
	~prefilter();
};

#endif
